﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HiUpdateTools.Client.Win
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Args = args;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;
            AppMutex = new Mutex(false, @"Global\" + appGuid);
            if (!Program.AppMutex.WaitOne(0, false))
            {
                return;
            }
       
            Application.Run(new UpdateForm());

        }

        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            using (ErrorForm frm = new ErrorForm()) 
            {
                frm.Error = e.Exception;
                frm.ShowDialog();
            }

        }
        private static string appGuid = "c0a76b5a-12ab-45c5-b9d9-d693faa6e7b9";

        public static Mutex AppMutex { get; set; }

        public static string[] Args { get; set; }
    }
}
